// 盛最多水的容器

let height = [1,8,6,2,5,4,8,3,7]

//  (j - i) * Math.min(height[j] , heigh[i]) // 最大值

var maxArea = function(height) {
let n = height.length
let left = 0, right = n - 1 , maxArea = 0
while(left < right) {
    let res = Math.min(height[left], height[right]) * (right - left)
    maxArea = Math.max(res, maxArea)
    if(height[left] < height[right]) left++
    else right--
}
return maxArea
}